#ifndef MDX2_SKIN_H_
#define MDX2_SKIN_H_

#if MDX_BUILD >= 28
/* Each MDX2_Skin (along with the data it references) is stored
   in a separate .skin file and NOT at MDX2_Header->ofsViews    */
#endif

#include <cstdint>
#include "Vector3D.h"

// Flags
#define FL_TEX_STATIC   0x10
#define FL_TEX_SHADERS  0x8000

// Description: Skinning data for a model
// Count:  MDX2_Header->nViews
// Offset: MDX2_Header->ofsViews
struct MDX2_Skin
{
#if MDX_BUILD >= 28
    char Magic[4];
#endif
    uint32_t nIndices;
    uint32_t ofsIndices;
    uint32_t nTriangles;
    uint32_t ofsTriangles;
    uint32_t nProperties;
    uint32_t ofsProperties;
    uint32_t nGeosets;
    uint32_t ofsGeosets;
    uint32_t nTextureMapping;
    uint32_t ofsTextureMapping;
    uint32_t Bones;
};

// Description: The geometric structure of mesh parts
// Count:  MDX2_Skin->nGeosets
// Offset: MDX2_Skin->ofsGeosets
struct MDX2_Geoset
{
    uint32_t ID; //always 0?
    uint16_t indVert;
    uint16_t numVert;
    uint16_t indFaces;
    uint16_t numFaces;
    uint16_t boneCount; //boneLookup total count (redundant?)
    uint16_t indBone; //indice into boneLookup
    uint16_t numBone; //number of bones used from boneLookup
    uint16_t RootBone; //flags? vital for sc2 engine rendering the geometry
    Vec3F Extents[2];
    float Radius;
};

// Description: Settings for mapping textures to geosets
// Count:  MDX2_Skin->nTextureMapping
// Offset: MDX2_Skin->ofsTextureMapping
struct MDX2_TextureMapping
{
    uint16_t Flags;
    uint16_t Shading;
    int16_t Target1;
    int16_t Target2;
    int16_t Color;
    int16_t RenderFlags;
    int16_t TextureUnit1;
    uint16_t Mode;
    int16_t Texture;
    int16_t TextureUnit2;
    int16_t Transparency;
    int16_t TextureAnim;
};

#endif // MDX2_SKIN_H_